// 1. 引入异步对象
import request from '@/utils/request'
// 2. 使用枚举来存储接口
enum Api {
  // 根据spuId 获取sku数据
  getSkuListApi = '/admin/product/findBySpuId',
  // 添加SkuInfo
  saveSkuInfoApi = '/admin/product/saveSkuInfo',
  // 查看所有的skuList数据
  getAllSkuListApi = '/admin/product/list',
  // 商品下架
  getCancelSaleApi = '/admin/product/cancelSale',
  // 商品上架
  getOnSaleApi = '/admin/product/onSale',
  // 删除sku
  deleteSkuApi = '/admin/product/deleteSku',
  // 根据id获取一条skuInfo详情信息
  getSkuInfoApi = '/admin/product/getSkuById'
}
// 3. 定义接口函数 
// 3.1 添加SkuInfo数据
export const reqSaveSkuInfo = (skuInfo) => {
  return request.post<any,any>(Api.saveSkuInfoApi,skuInfo)
}

// 3.2 根据spuId获取sku列表
export const reqGetSkuListData = (spuId:number) => {
  return request.get<any,any>(Api.getSkuListApi+`/${spuId}`)
}

// 3.3 查看所有的SKU列表 
export const reqGetAllSkuListData = (page:number,limit:number)=>{
  return request.get<any,any>(Api.getAllSkuListApi+`/${page}/${limit}`)
}

// 3.4 商品上架
export const reqGetOnSale = (skuId:number)=>{
  return request.get<any,any>(Api.getOnSaleApi+`/${skuId}`)
}
// 3.5 商品下架
export const reqGetCancelSale = (skuId:number)=>{
  return request.get<any,any>(Api.getCancelSaleApi+`/${skuId}`)
}
// 3.6 删除sku
export const reqDeleteSku = (skuId:number)=>{
  return request.delete<any,any>(Api.deleteSkuApi+`/${skuId}`)
}

// 3.7 获取sku详情信息
export const reqGetOneSkuInfo = (skuId:number)=>{
  return request.get(Api.getSkuInfoApi+`/${skuId}`)
}